package com.huike.clues.service.impl;

import com.github.pagehelper.PageHelper;
import com.huike.clues.domain.SysNotice;
import com.huike.clues.mapper.SysNoticeMapper;
import com.huike.clues.service.ISysNoticeService;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class ISysNoticeServiceImpl implements ISysNoticeService {
    @Autowired
    private SysNoticeMapper sysNoticeMapper;

    /**
     * 获取系统提醒下拉列表
     * @param sysNotice
     * @return
     */
    @Override
    public List<SysNotice> list(SysNotice sysNotice) {
        return sysNoticeMapper.list(sysNotice);
    }

    /**
     * 分页查询
     * @param sysNotice
     * @return
     */
    @Override
    public List<SysNotice> noticeList(String status) {
        log.info("测试 " + sysNoticeMapper.noticeList(status));
        return sysNoticeMapper.noticeList(status);

    }

    /**
     * 查询详细信息
     * @param noticeId
     * @return
     */
    @Override
    public SysNotice details(Integer noticeId) {
        if (noticeId != null) {
            return sysNoticeMapper.details(noticeId);
        }
        return null;
    }

    @Override
    public void markAsRead(Integer noticeId) {
        SysNotice sysNotice = sysNoticeMapper.selectSysNoticeById(noticeId);
        if (sysNotice != null) {
            sysNotice.setStatus("1"); // 将状态设为已读
            sysNoticeMapper.updateSysNotice(sysNotice);
        }
    }


}
